/*
 * @Author: 郝奔 1425466221@qq.com
 * @Date: 2024-11-29 10:20:27
 * @LastEditors: 郝奔 1425466221@qq.com
 * @LastEditTime: 2024-12-26 11:00:45
 * @FilePath: /HG-dqbasic_open_platform/src/framework/api/menu/index.ts
 * @Description: 
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved. 
 */
import { default as request, cloud } from '@/framework/utils/request';
import {
  FormDataType,
  DetailIdType,
  MenuListType,
  UpdateFlagType,
  MenuButtonListType,
  MenuForm,
  InterfaceListType,
  InterfaceIDType,
  MenuButtonDetailIdType, MenuButtonDetailIdsType, AddMenuResourceBindType,
  InterfaceDetailType,
  InterfaceAssociateType,
  ResourceType,servesListType
} from './types';

import { ResultData, ResultDataList } from '@/framework/api/common';
import { LetMenuAll } from './types'
export default {
//门户 应用card
getServesMenu(): Promise<ResultData<servesListType[]>> {
  return request({
    url: '/permission/sysAcInfo/getPortalApp',
    method: 'get',
  });
},

  //获取菜单列表
  getSysMenuList(params: Partial<MenuListType>): Promise<ResultDataList<MenuListType>> {
    return request({
      url: cloud.dqBasic + '/sysMenu/list',
      method: 'get',
      params
    });
  },
  // 代码生成查询菜单
  getMenuList(params: Partial<MenuListType>): Promise<ResultData<MenuListType[]>> {
    return request({
      url: cloud.dqBasic + '/sysMenu/menuList',
      method: 'get',
      params
    });
  },
  //添加菜单
  addSysMenu(data: Partial<FormDataType>): Promise<ResultData<null>> {
    return request({
      url: cloud.dqBasic + '/sysMenu/add',
      method: 'post',
      data
    });
  },
  //修改菜单
  editSysMenu(data: Partial<FormDataType>): Promise<ResultData<null>> {
    return request({
      url: cloud.dqBasic + '/sysMenu/edit',
      method: 'post',
      data
    });
  },
  //获取菜单详情    {'id':123}   
  getSysMenuDetail(params: DetailIdType): Promise<ResultData<MenuListType>> {
    return request({
      url: cloud.dqBasic + '/sysMenu/detail',
      method: 'get',
      params
    });
  },
  // 删除菜单
  deleteSysMenu(data: DetailIdType): Promise<ResultData<null>> {
    return request({
      url: cloud.dqBasic + '/sysMenu/delete',
      method: 'post',
      data
    });
  },
  // 修改菜单状态
  updateStatusSysMenu(data: UpdateFlagType): Promise<ResultData<null>> {
    return request({
      url: cloud.dqBasic + '/sysMenu/updateStatus',
      method: 'post',
      data
    });
  },
  // getLeftMenu(): Promise<ResultDataList<MenuList>> {
  //   return request({
  //     url: cloud.dqBasic + '/sysMenu/getLeftMenusAntdv',
  //     method: 'get',
  //   });
  // },

  //
  getSysMenuTree(params: Partial<FormDataType>): Promise<ResultData<MenuListType[]>> {
    return request({
      url: cloud.dqBasic + '/sysMenu/tree',
      method: 'get',
      params
    });
  },
  //获取菜单的资源分配分页列表
  getMenuResourcesPage(params: Partial<InterfaceListType>): Promise<ResultDataList<InterfaceListType>> {
    return request({
      url: cloud.dqBasic + '/sysMenuResource/getMenuResourcesPage',
      method: 'get',
      params
    });
  },
  //批量解除菜单资源绑定
  batchDeleteMenuResourceBind(data: InterfaceDetailType): Promise<ResultData<null>> {
    return request({
      url: cloud.dqBasic + '/sysMenuResource/batchDeleteMenuResourceBind',
      method: 'post',
      data
    });
  },

  //查询菜单按钮管理列表数据
  getSysMenuButton(params: Partial<MenuButtonListType>): Promise<ResultDataList<MenuButtonListType>> {
    return request({
      url: cloud.dqBasic + '/sysMenuButton/pageList',
      method: 'get',
      params
    });
  },
  // 获取菜单的资源列表
  getResourceCheckedList(params: Partial<InterfaceAssociateType>): Promise<ResultData<InterfaceAssociateType[]>> {
    return request({
      url: cloud.dqBasic + '/sysMenuResource/getResourceCheckedList',
      method: 'get',
      params
    });
  },
  // 按钮查询已绑定的接口
  getAllResourceChecked(params: InterfaceIDType): Promise<ResultData<InterfaceAssociateType[]>> {
    return request({
      url: cloud.dqBasic + '/sysMenuResource/getAllResourceChecked',
      method: 'get',
      params
    });
  },
  // 资源分类列表
  getResourceTypeList(): Promise<ResultData<ResourceType[]>> {
    return request({
      url: cloud.dqBasic + '/sysMenuResource/getResourceTypeList',
      method: 'get',
    });
  },

  //一键添加默认按钮
  addSysDefaultMenuButton(data: DetailIdType): Promise<ResultData<null>> {
    return request({
      url: cloud.dqBasic + '/sysMenuButton/addSystemDefaultButton',
      method: 'post',
      data
    });
  },
  //新增
  addSysMenuButton(data: Partial<MenuButtonListType>): Promise<ResultData<null>> {
    return request({
      url: cloud.dqBasic + '/sysMenuButton/add',
      method: 'post',
      data
    });
  },
  //修改
  editSysMenuButton(data: Partial<MenuButtonListType>): Promise<ResultData<null>> {
    return request({
      url: cloud.dqBasic + '/sysMenuButton/edit',
      method: 'post',
      data
    });
  },
  //删除
  deleteSysMenuButton(data: MenuButtonDetailIdType): Promise<ResultData<null>> {
    return request({
      url: cloud.dqBasic + '/sysMenuButton/delete',
      method: 'post',
      data
    });
  },
  //批量删除
  batchDeleteMenuButton(data: MenuButtonDetailIdsType): Promise<ResultData<null>> {
    return request({
      url: cloud.dqBasic + '/sysMenuButton/batchDelete',
      method: 'post',
      data
    });
  },
  // 设置菜单资源绑定
  addMenuResourceBind(data: AddMenuResourceBindType): Promise<MenuButtonListType> {
    return request({
      url: cloud.dqBasic + '/sysMenuResource/addMenuResourceBind',
      method: 'post',
      data
    });
  },

}

/**
 * 获取导航菜单
 */
export function getFunctionInfoByAppCode(params:{appCode:string}): Promise<ResultData<LetMenuAll>> {
  return request({
      url: cloud.businessBasic + '/sysAcInfo/getFunctionInfoByAppCode',
      method: 'get',
      params
  });
}

/**
 * 获取菜单表格列表
 *
 * @param queryParams
//  */
// export function listMenus(queryParams: MenuQuery): Promise<Menu[]> {
//   return request({
//     url: '/api/v1/menus',
//     method: 'get',
//     params: queryParams
//   });
// }

/**
 * 获取菜单下拉树形列表
 */
export function listMenuOptions(): Promise<OptionType[]> {
  return request({
    url: '/api/v1/menus/options',
    method: 'get'
  });
}

/**
 * 获取资源(菜单+权限)树形列表
//  */
// export function listResources(): Promise<Resource[]> {
//   return request({
//     url: '/api/v1/menus/resources',
//     method: 'get'
//   });
// }

/**
 * 获取菜单详情
 * @param id
 */
export function getMenuDetail(id: string): Promise<MenuForm> {
  return request({
    url: '/api/v1/menus/' + id,
    method: 'get'
  });
}
